var FOLDER_URL = "{% url 'file' project_id=request.tracer.project.id %}"
$(function(){
    initAddModel();
    bindModelSubmit();
});
function initAddModel(){
    $('#addModal').on('show.bs.modal', function (event) {
  var button = $(event.relatedTarget) // Button that triggered the modal
  var recipient = button.data('whatever') // Extract info from data-* attributes
  var modal = $(this)
  modal.find('.modal-title').text(recipient)
    })
}
function bindModelSubmit(){
    $("#btnFormSubmit").click(function(){
        $.ajax({
            url:FOLDER_URL,
            type:"POST",
            data:$("#form").serialize(),
            dataType:"JSON",
            success:function(res){
                if(res.status){
                    //正确
                    location.href = location.href;
                }else{
                    // 错误信息
                    console.log(data)
                    $.each(res.error, function (key, value) {
                        $("#id_" + key).next().text(value[0]);
                    })
                }
            }
        })
    })
}